package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.QuestionFormDTO;
import com.tianji.learning.domain.query.QuestionPageQuery;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 互动提问的问题表 前端控制器
 * </p>
 *
 * @author EllieHy
 * @since 2024-06-01
 */
@RestController
@RequestMapping("/questions")
@RequiredArgsConstructor
@Slf4j
@Api("互动问题相关接口")
public class InteractionQuestionController {
	
	private final IInteractionQuestionService questionService;
	@ApiOperation("根据id查询问题详情")
	@GetMapping("/{id}")
	public QuestionVO queryQuestionById(@ApiParam(value = "问题id", example = "1") @PathVariable("id") Long id){
		return questionService.queryQuestionById(id);
	}
	@ApiOperation("分页查询互动问题")
	@GetMapping("page")
	public PageDTO<QuestionVO> queryQuestionPage(QuestionPageQuery query){
		return questionService.queryQuestionPage(query);
	}
	
	
	@ApiOperation("新增问题接口")
	@PostMapping
	public void saveQuestion(@RequestBody @Validated QuestionFormDTO questionFormDTO) {
		questionService.saveQuestion(questionFormDTO);
	}
	
	@ApiOperation("修改问题接口")
	@PutMapping("/{id}")
	public void updateQuestion(@PathVariable Long id,
	                           @RequestBody @Validated QuestionFormDTO questionFormDTO) {
		questionService.updateQuestion(id, questionFormDTO);
	}
	
	
	
	
}
